﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

namespace PeisongWeb
{
    public partial class seller_info : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                menu1.menucss = "2";
                getDetails();
            }
        }
        protected void getDetails()
        {
            int userid = logic.customer.userId;
            CustomerEntity _cus = logic.customer.getById(userid);
            txt_username.Value = _cus.Username;
            hid_Pwd.Value = _cus.Password;
            txt_email.Value = _cus.Email;
            txt_realname.Value = _cus.Realname;
            txt_phone.Value = _cus.Phone;
            hid_companyid.Value = _cus.CompanyId.ToString();
            hid_isAdmin.Value = _cus.IsAdmin.ToString();
            hid_isRefuse.Value = _cus.IsRefuse.ToString();
            hid_expireDt.Value = _cus.expireDt.ToString();
            //string type = logic.company.getById(_cus.CompanyId).Type;
            //if (type == "1")
            //{
            //    menu1.menucss = "6";
            //}
            //else if (type == "2")
            //{
            //    menu1.menucss = "7";
            //}
            //else if (type == "3")
            //{
            //    menu1.menucss = "3";
            //}
        }
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            if (Request.Headers["Accept"] != "*/*")
            {
                CustomerEntity _cus = new CustomerEntity();
                _cus.CustomerId = logic.customer.userId;
                _cus.Username = txt_username.Value.Trim();
                _cus.Password = hid_Pwd.Value.Trim();
                _cus.Email = txt_email.Value.Trim();
                _cus.Realname = txt_realname.Value.Trim();
                _cus.Phone = txt_phone.Value.Trim();
                _cus.CompanyId = Convert.ToInt32(hid_companyid.Value);
                _cus.IsAdmin = Convert.ToBoolean(hid_isAdmin.Value);
                _cus.IsRefuse = Convert.ToBoolean(hid_isRefuse.Value);
                _cus.expireDt = Convert.ToDateTime(hid_expireDt.Value);
                logic.customer.update(_cus);
                Library.Script.ClientMsg("修改成功！");
            }
        }
    }
}
